package qianFeng.day2;

import java.util.Scanner;

public class Atm {
    static int money=0;

    public static void main(String[] args) {
        new AtmControl().control(money);
    }
}
class AtmControl{
    public int control(int money){
        int sw_control;
        boolean signal=true;

        Scanner moneyDetial=new Scanner(System.in);
        while (signal) {
            System.out.println("1.存款  2.取款 3.退出");
            System.out.print("请选择你要办理的业务：");
            sw_control=new Scanner(System.in).nextInt();
            switch (sw_control){
                case 1:
                    System.out.print("请输入存款金额：");
                    money+=moneyDetial.nextInt();
                    System.out.println("存款成功！");
                    System.out.println("当前余额为："+money);
                    System.out.println("-------------------------------");
                    break;
                case 2:
                    System.out.print("请输入取款金额：");
                    int take_money=moneyDetial.nextInt();
                    if (take_money>money)
                        System.out.println("金额不足，无法完成业务！");
                    else {
                        money -= take_money;
                        System.out.println("取款成功！");
                        System.out.println("当前余额为："+money);
                        System.out.println("-------------------------------");
                    }
                    break;
                case 3:
                    System.out.println("感谢你的使用！");
                    signal=false;
                    break;
                default:System.out.println("没有此选项，请重新选择！");
            }
        }
        return money;
    }
}
